<template>
    <div class="new">
        <van-list
        v-model="loading"
        :finished="finished"
        finished-text="没有更多了"
        @load="onLoad"
        >
            <div v-for="(item,index) in newList" :key="index">
                <!-- <div v-if="item.image.length === 0"></div>
                <div v-if="item.image.length === 1"></div>
                <div v-if="item.image.length > 1"></div> -->
                <van-card
                num="2"
                price="2.00"
                desc="描述信息"
                :title="item.title"
                thumb="https://img01.yzcdn.cn/vant/ipad.jpeg"
                />
            </div>
        </van-list>
       
    </div>
</template>

<script>
export default {
    data() {
        return {
            newList: [],
            loading:false,
            finished: false,
            pageIndex: 1,
        }
    },
    created() {
       
    },
    methods: {
        onLoad() {
            console.log('指向')
                 this.loading= true;
        // 异步更新数据
        // setTimeout 仅做示例，真实场景中一般为 ajax 请求
            this.getList()
        },
        getList() {
             return this.$api.getNews({
                pageIndex:this.pageIndex,
                pageSize:10
            }).then(res=>{
                this.newList = this.newList.concat(res.data)
                this.loading= false;
                this.pageIndex+=1
                if(res.data.length == 0) {
                    this.finished = true
                }

            })
        }
    }
}
</script>

<style>
.new{
    width:100%;
    height:100%;
}
</style>